import { CvNodeData, ExternalData } from "@/components/workflow/cv-node";
import { ModalType, ModelMenuItem, TaskType } from "./types";
import { Edge, Node } from "@xyflow/react";

export const ModalMap: Record<TaskType, ModalType[]> = {
  preprocessing: ["RGB", "IR", "SAR"],
  classification: ["RGB", "IR", "SAR"],
  detection: ["RGB", "IR", "SAR"],
  tracking: ["RGB", "IR", "SAR"],
  search: ["RGB", "IR", "SAR"],
};

// Task type background color configuration
export const taskTypeColors: Record<TaskType, string> = {
  preprocessing:
    "bg-indigo-900 border-indigo-400 text-indigo-100 focus:bg-indigo-900, focus:text-indigo-100",
  classification:
    "bg-sky-900 border-sky-400 text-sky-100 focus:bg-sky-900, focus:text-sky-100",
  detection:
    "bg-purple-900 border-purple-400 text-purple-100 focus:bg-purple-900, focus:text-purple-100",
  tracking:
    "bg-violet-900 border-violet-400 text-violet-100 focus:bg-violet-900, focus:text-violet-100",
  search:
    "bg-blue-900 border-blue-400 text-blue-100 focus:bg-blue-900, focus:text-blue-100",
};
// Status configuration - using Chinese labels
export const statusConfig: Record<string, { text: string }> = {
  idle: { text: "空闲" },
  running: { text: "运行中" },
  success: { text: "成功" },
  failed: { text: "失败" },
};

export const taskExternalData: Partial<
  Record<TaskType, { inputs: ExternalData[]; outputs: ExternalData[] }>
> = {
  preprocessing: {
    inputs: [
      {
        name: "source_image",
        type: "image",
        value: "",
        reference: "",
      },
    ],
    outputs: [
      {
        name: "result",
        type: "image",
        value: "",
        reference: "",
      },
    ],
  },
  detection: {
    inputs: [
      {
        name: "target_image",
        type: "image",
        value: "",
        reference: "",
      },
    ],
    outputs: [
      {
        name: "result_information",
        type: "text",
        value: "",
        reference: "",
      },
      {
        name: "result",
        type: "image",
        value: "",
        reference: "",
      },
    ],
  },
  classification: {
    inputs: [
      {
        name: "target_image",
        type: "image",
        value: "",
        reference: "",
      },
    ],
    outputs: [
      {
        name: "result_information",
        type: "text",
        value: "",
        reference: "",
      },
      {
        name: "result",
        type: "image",
        value: "",
        reference: "",
      },
    ],
  },
  search: {
    inputs: [
      {
        name: "query",
        type: "image",
        value: "",
        reference: "",
      },
      {
        name: "query_content",
        type: "text",
        value: "",
        reference: "",
      },
      {
        name: "gallery-1",
        type: "image",
        value: "",
        reference: "",
      },
      {
        name: "gallery-2",
        type: "image",
        value: "",
        reference: "",
      },
      {
        name: "gallery-3",
        type: "image",
        value: "",
        reference: "",
      },
      {
        name: "gallery-content",
        type: "text",
        value: "",
        reference: "",
      },
    ],
    outputs: [
      {
        name: "result-1",
        type: "image",
        value: "",
        reference: "",
      },
      {
        name: "result-2",
        type: "image",
        value: "",
        reference: "",
      },
      {
        name: "result-3",
        type: "image",
        value: "",
        reference: "",
      },
      {
        name: "result_information",
        type: "text",
        value: "",
        reference: "",
      },
    ],
  },
  tracking: {
    inputs: [
      {
        name: "image-1",
        type: "image",
        value: "",
        reference: "",
      },
      {
        name: "image-2",
        type: "image",
        value: "",
        reference: "",
      },
      {
        name: "init-bbox",
        type: "text",
        value: "",
        reference: "",
      },
    ],
    outputs: [
      {
        name: "result",
        type: "image",
        value: "",
        reference: "",
      },
    ],
  },
};

export const initialNodes: Node<CvNodeData>[] = [];

export const initialEdges: Edge[] = [];

export const modelMenuData: ModelMenuItem[] = [
  {
    task: "preprocessing",
    label: "预处理",
    models: [
      "none",
      "denoise",
      "derain",
      "dehaze",
      "gamma",
      "retinex",
      "usm",
      "th_trans",
    ],
  },
  {
    task: "classification",
    label: "分类",
    models: [
      "ir_googlenet",
      "ir_resnet",
      "ir_resnext",
      "ir_svm",
      "ir_vgg",
      "rgb_googlenet",
      "rgb_resnet",
      "rgb_resnext",
      "rgb_svm",
      "rgb_vgg",
      "sar_googlenet",
      "sar_resnet",
      "sar_resnext",
      "sar_svm",
      "sar_vgg",
    ],
  },
  {
    task: "detection",
    label: "检测",
    models: [
      "ir_yolov12l",
      "rgb-2_yolov12n",
      "rgb_yolov12n",
      "sar_yolov12m",
      "ir_yolov12m",
      "rgb-2_yolov12s",
      "rgb_yolov12s",
      "sar_yolov12n",
      "ir_yolov12n",
      "rgb-2_yolov5n",
      "rgb_yolov5n",
      "sar_yolov12s",
      "ir_yolov12s",
      "rgb-2_yolov8n",
      "rgb_yolov8n",
      "sar_yolov5n",
      "rgb-2_yolov11n",
      "rgb_yolov11n",
      "sar_detr",
      "sar_yolov8n",
      "rgb-2_yolov12l",
      "rgb_yolov12l",
      "sar_yolov11n",
      "rgb-2_yolov12m",
      "rgb_yolov12m",
      "sar_yolov12l",
    ],
  },
  {
    task: "search",
    label: "搜索",
    models: [
      "IR/SeqNet",
      "IR/COAT",
      "IR/SAT",
      "RGB/SeqNet",
      "RGB/COAT",
      "RGB/SAT",
    ],
  },
  {
    task: "tracking",
    label: "跟踪",
    models: ["kcf", "keeptrack"],
  },
];
